<?php
class Server {
  public static function get_objs($orm, $sys, $inst, $is_iframe) {
    $req = json_decode(Utils::get_param('req', '[]'));
    
    
    $opts = new stdClass(); 
    $opts->cd = 't.subject LIKE :v0';
    $opts->cdv = array(':v0' => '%' . $req->search . '%');
    $data = $orm->get('pb_ht_newsletter', $req->o, $req->q, $req->pg, SIZE, $opts);
    echo json_encode($data);
  }
  
  public static function delete_obj($orm, $sys, $inst, $is_iframe) {
    $req = json_decode(Utils::get_param('req', '[]'));
    
    if (isset($req->sent) || $req->sent != '0000-00-00 00:00:00') {
      echo '无法删除已发送邮件';
      return;
    }
    $orm->delete('pb_ht_newsletter', $req);
    if (isset($req->__pg)) {
      $data = $orm->get('pb_ht_newsletter', $req->__o, $req->__q, $req->__pg, SIZE, NULL);
      echo json_encode($data);
    }
  }
}
?>